import time

from selenium import webdriver


driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)


url = ["https://www.baidu.com", "https://www.jd.com"]

for i in range(len(url)):
    if i == 0:
        driver.get(url[i])
        # print(driver.current_window_handle)
    else:
        js = f"window.open('{url[i]}')"
        # print(js)
        driver.execute_script(js)
handles = driver.window_handles
# print(handles)
driver.switch_to.window(handles[1])
time_stamp = time.strftime("%Y%m%d_%H%M%S")
driver.get_screenshot_as_file("./%s.png" % time_stamp)


